home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15584 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  50 lines

  1. Path: prodigy.com!usenet
  2. From: ERQK75A@prodigy.com (Joe Larson)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A real basic problem?:  (code!) long integers or compiler problem?
  5. Date: 20 Apr 1996 02:37:40 GMT
  6. Organization: Prodigy Services Company  1-800-PRODIGY
  7. Distribution: world
  8. Message-ID: <4l9ilk$12o6@useneta1.news.prodigy.com>
  9. References: <4l3mom$f26@newsbf02.news.aol.com> <4l699u$cgo@newsbf02.news.aol.com> <4l70g7$m7i@ccshst05.uoguelph.ca>
  10. NNTP-Posting-Host: innugap5-int.news.prodigy.com
  11. X-Newsreader: Version 1.2
  12.  
  13. I think you're right, Toby - except it'll take about 65,535 times longer, 
  14. and not quite as a long as a day or 2...!
  15.  
  16. I compiled the program with Borland C++ 4.5 and had no problem running it 
  17. on a Pentium90 - but I had to wait a little while. I inserted timestamps 
  18. around maxlng() to see that it took 269 secs. For a 486DX2(-66?) it'll 
  19. take about twice as long. Check it out.
  20.  
  21. #include <stdio.h>
  22. #include <time.h>
  23.  
  24. void main()
  25. {
  26. long i;
  27. long maxlng();
  28. time_t st, et;
  29.  
  30. time(&st);
  31. i=maxlng();
  32. time(&et);
  33. printf("max i= %ld,  max i+1= %ld",i,i+1);
  34. printf("\nSecs = %ld.", et-st);
  35. }
  36.  
  37. long maxlng()
  38. {
  39. long first, b;
  40.     first = 10000;
  41. while (first >= 0)
  42. {
  43. b= first;
  44. first++;
  45. }
  46.     return (b);
  47. }
  48.  
  49.  
  50.